﻿<Window x:Class="SyncTool.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SyncTool"
        Name="main"
        Title="Sync" Height="320" Width="525">
  <Window.Resources>
    <local:BoolConverter x:Key="boolConverter" />
  </Window.Resources>
  <Grid>
    <StackPanel  Margin="10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
      <StackPanel.Resources>
        <Style TargetType="Grid"  >
          <Style.Setters >
            <Setter Property="Margin" Value="0,10,0,0" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
          </Style.Setters>
        </Style>

        <Style TargetType="TextBlock"  >
          <Style.Setters >
            <Setter Property="Grid.Column" Value="0" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="Margin" Value="10,0,3,0" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
          </Style.Setters>
        </Style>

        <Style TargetType="TextBox"  >
          <Style.Setters >
            <Setter Property="Grid.Column" Value="1" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Margin" Value="10,0,20,0" />
            <Setter Property="Width" Value="200" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
          </Style.Setters>
        </Style>

      </StackPanel.Resources>

      <Grid IsEnabled="{Binding ElementName=main,Path=IsEdit}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition  Width="120"/>
          <ColumnDefinition  Width="200*"/>
        </Grid.ColumnDefinitions>
        <Button   HorizontalAlignment="Right"
                  x:Name="btnSource"
                  Content="Source:"
                  Click="btnSource_Click" >
        </Button>
        <TextBox  x:Name="tbSource" Text="{Binding Path=Source,ElementName=main,Mode=TwoWay}" />
      </Grid>


      <Grid IsEnabled="{Binding ElementName=main,Path=IsEdit}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition  Width="120"/>
          <ColumnDefinition  Width="200*"/>
        </Grid.ColumnDefinitions>
        <Button   HorizontalAlignment="Right"
                  x:Name="btnDestination"
                  Content="Destination:"
                  Click="btnDestination_Click"   >
        </Button>
        <TextBox  x:Name="tbDestination"  Text="{Binding ElementName=main,Path=Destination,Mode=TwoWay}"/>
      </Grid>

      <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Button Content="Go" Height="42" 
              IsEnabled="{Binding ElementName=main,Path=IsEdit}"
              Margin="0,10,20,0"
              IsDefault="True"
              HorizontalAlignment="Center"
              Click="btnGo_Click" Name="btnGo" VerticalAlignment="Top" Width="169"   />

        <Button Content="Cancel" Height="42" 
             IsEnabled="{Binding ElementName=main,Path=IsEdit,Converter={StaticResource boolConverter}}"
              Margin="0,10,0,0"
              HorizontalAlignment="Center"
              Click="btnCancel_Click" Name="btnCancel" VerticalAlignment="Top" Width="169"   >
        </Button>
      </StackPanel>

      <TextBlock Name="tb" Margin="0,10,0,0" HorizontalAlignment="Stretch" TextWrapping="Wrap" />
      <CheckBox Content="完成后关机" x:Name="chkShutdown"   Margin="10,0,0,0"/>
    </StackPanel>

  </Grid>
</Window>
